﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using HYSoft.IDAL;
using Maticsoft.DBUtility;
using System.Data;//Please add references
namespace HYSoft.SQLServerDAL
{
    /// <summary>
    /// 数据访问类:monitor_info
    /// </summary>
    public partial class monitor_info : Imonitor_info
    {
        public monitor_info()
        { }
        #region  BasicMethod

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int index, string m_area_name, string m_area_id, string addr, string type, string level, int population, int count, string contact_name1, string contact_mobile1, string contact_name2, string contact_mobile2, string contact_name3, string contact_mobile3, string upunit1, string upcontact_name1, string upcontact_mobile1, string upunit2, string upcontact_name2, string upcontact_mobile2, int intvalue1, int intvalue2, int intvalue3, string charvalue1, string charvalue2, string charvalue3, int user_index, string coordinates_x, string coordinates_y)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from monitor_info");
            strSql.Append(" where index=@index and m_area_name=@m_area_name and m_area_id=@m_area_id and addr=@addr and type=@type and level=@level and population=@population and count=@count and contact_name1=@contact_name1 and contact_mobile1=@contact_mobile1 and contact_name2=@contact_name2 and contact_mobile2=@contact_mobile2 and contact_name3=@contact_name3 and contact_mobile3=@contact_mobile3 and upunit1=@upunit1 and upcontact_name1=@upcontact_name1 and upcontact_mobile1=@upcontact_mobile1 and upunit2=@upunit2 and upcontact_name2=@upcontact_name2 and upcontact_mobile2=@upcontact_mobile2 and intvalue1=@intvalue1 and intvalue2=@intvalue2 and intvalue3=@intvalue3 and charvalue1=@charvalue1 and charvalue2=@charvalue2 and charvalue3=@charvalue3 and user_index=@user_index and coordinates_x=@coordinates_x and coordinates_y=@coordinates_y ");
            SqlParameter[] parameters = {
					new SqlParameter("@index", SqlDbType.Int,4),
					new SqlParameter("@m_area_name", SqlDbType.VarChar,255),
					new SqlParameter("@m_area_id", SqlDbType.VarChar,50),
					new SqlParameter("@addr", SqlDbType.VarChar,255),
					new SqlParameter("@type", SqlDbType.VarChar,255),
					new SqlParameter("@level", SqlDbType.VarChar,255),
					new SqlParameter("@population", SqlDbType.Int,4),
					new SqlParameter("@count", SqlDbType.Int,4),
					new SqlParameter("@contact_name1", SqlDbType.VarChar,50),
					new SqlParameter("@contact_mobile1", SqlDbType.VarChar,50),
					new SqlParameter("@contact_name2", SqlDbType.VarChar,50),
					new SqlParameter("@contact_mobile2", SqlDbType.VarChar,50),
					new SqlParameter("@contact_name3", SqlDbType.VarChar,50),
					new SqlParameter("@contact_mobile3", SqlDbType.VarChar,50),
					new SqlParameter("@upunit1", SqlDbType.VarChar,255),
					new SqlParameter("@upcontact_name1", SqlDbType.VarChar,50),
					new SqlParameter("@upcontact_mobile1", SqlDbType.VarChar,50),
					new SqlParameter("@upunit2", SqlDbType.VarChar,255),
					new SqlParameter("@upcontact_name2", SqlDbType.VarChar,50),
					new SqlParameter("@upcontact_mobile2", SqlDbType.VarChar,50),
					new SqlParameter("@intvalue1", SqlDbType.Int,4),
					new SqlParameter("@intvalue2", SqlDbType.Int,4),
					new SqlParameter("@intvalue3", SqlDbType.Int,4),
					new SqlParameter("@charvalue1", SqlDbType.VarChar,255),
					new SqlParameter("@charvalue2", SqlDbType.VarChar,255),
					new SqlParameter("@charvalue3", SqlDbType.VarChar,255),
					new SqlParameter("@user_index", SqlDbType.Int,4),
					new SqlParameter("@coordinates_x", SqlDbType.VarChar,50),
					new SqlParameter("@coordinates_y", SqlDbType.VarChar,50)			};
            parameters[0].Value = index;
            parameters[1].Value = m_area_name;
            parameters[2].Value = m_area_id;
            parameters[3].Value = addr;
            parameters[4].Value = type;
            parameters[5].Value = level;
            parameters[6].Value = population;
            parameters[7].Value = count;
            parameters[8].Value = contact_name1;
            parameters[9].Value = contact_mobile1;
            parameters[10].Value = contact_name2;
            parameters[11].Value = contact_mobile2;
            parameters[12].Value = contact_name3;
            parameters[13].Value = contact_mobile3;
            parameters[14].Value = upunit1;
            parameters[15].Value = upcontact_name1;
            parameters[16].Value = upcontact_mobile1;
            parameters[17].Value = upunit2;
            parameters[18].Value = upcontact_name2;
            parameters[19].Value = upcontact_mobile2;
            parameters[20].Value = intvalue1;
            parameters[21].Value = intvalue2;
            parameters[22].Value = intvalue3;
            parameters[23].Value = charvalue1;
            parameters[24].Value = charvalue2;
            parameters[25].Value = charvalue3;
            parameters[26].Value = user_index;
            parameters[27].Value = coordinates_x;
            parameters[28].Value = coordinates_y;

            return DbHelperSQL.Exists(strSql.ToString(), parameters);
        }


        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(HYSoft.Model.monitor_info model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into monitor_info(");
            strSql.Append("index,m_area_name,m_area_id,addr,type,level,population,count,contact_name1,contact_mobile1,contact_name2,contact_mobile2,contact_name3,contact_mobile3,upunit1,upcontact_name1,upcontact_mobile1,upunit2,upcontact_name2,upcontact_mobile2,intvalue1,intvalue2,intvalue3,charvalue1,charvalue2,charvalue3,user_index,coordinates_x,coordinates_y)");
            strSql.Append(" values (");
            strSql.Append("@index,@m_area_name,@m_area_id,@addr,@type,@level,@population,@count,@contact_name1,@contact_mobile1,@contact_name2,@contact_mobile2,@contact_name3,@contact_mobile3,@upunit1,@upcontact_name1,@upcontact_mobile1,@upunit2,@upcontact_name2,@upcontact_mobile2,@intvalue1,@intvalue2,@intvalue3,@charvalue1,@charvalue2,@charvalue3,@user_index,@coordinates_x,@coordinates_y)");
            SqlParameter[] parameters = {
					new SqlParameter("@index", SqlDbType.Int,4),
					new SqlParameter("@m_area_name", SqlDbType.VarChar,255),
					new SqlParameter("@m_area_id", SqlDbType.VarChar,50),
					new SqlParameter("@addr", SqlDbType.VarChar,255),
					new SqlParameter("@type", SqlDbType.VarChar,255),
					new SqlParameter("@level", SqlDbType.VarChar,255),
					new SqlParameter("@population", SqlDbType.Int,4),
					new SqlParameter("@count", SqlDbType.Int,4),
					new SqlParameter("@contact_name1", SqlDbType.VarChar,50),
					new SqlParameter("@contact_mobile1", SqlDbType.VarChar,50),
					new SqlParameter("@contact_name2", SqlDbType.VarChar,50),
					new SqlParameter("@contact_mobile2", SqlDbType.VarChar,50),
					new SqlParameter("@contact_name3", SqlDbType.VarChar,50),
					new SqlParameter("@contact_mobile3", SqlDbType.VarChar,50),
					new SqlParameter("@upunit1", SqlDbType.VarChar,255),
					new SqlParameter("@upcontact_name1", SqlDbType.VarChar,50),
					new SqlParameter("@upcontact_mobile1", SqlDbType.VarChar,50),
					new SqlParameter("@upunit2", SqlDbType.VarChar,255),
					new SqlParameter("@upcontact_name2", SqlDbType.VarChar,50),
					new SqlParameter("@upcontact_mobile2", SqlDbType.VarChar,50),
					new SqlParameter("@intvalue1", SqlDbType.Int,4),
					new SqlParameter("@intvalue2", SqlDbType.Int,4),
					new SqlParameter("@intvalue3", SqlDbType.Int,4),
					new SqlParameter("@charvalue1", SqlDbType.VarChar,255),
					new SqlParameter("@charvalue2", SqlDbType.VarChar,255),
					new SqlParameter("@charvalue3", SqlDbType.VarChar,255),
					new SqlParameter("@user_index", SqlDbType.Int,4),
					new SqlParameter("@coordinates_x", SqlDbType.VarChar,50),
					new SqlParameter("@coordinates_y", SqlDbType.VarChar,50)};
            parameters[0].Value = model.index;
            parameters[1].Value = model.m_area_name;
            parameters[2].Value = model.m_area_id;
            parameters[3].Value = model.addr;
            parameters[4].Value = model.type;
            parameters[5].Value = model.level;
            parameters[6].Value = model.population;
            parameters[7].Value = model.count;
            parameters[8].Value = model.contact_name1;
            parameters[9].Value = model.contact_mobile1;
            parameters[10].Value = model.contact_name2;
            parameters[11].Value = model.contact_mobile2;
            parameters[12].Value = model.contact_name3;
            parameters[13].Value = model.contact_mobile3;
            parameters[14].Value = model.upunit1;
            parameters[15].Value = model.upcontact_name1;
            parameters[16].Value = model.upcontact_mobile1;
            parameters[17].Value = model.upunit2;
            parameters[18].Value = model.upcontact_name2;
            parameters[19].Value = model.upcontact_mobile2;
            parameters[20].Value = model.intvalue1;
            parameters[21].Value = model.intvalue2;
            parameters[22].Value = model.intvalue3;
            parameters[23].Value = model.charvalue1;
            parameters[24].Value = model.charvalue2;
            parameters[25].Value = model.charvalue3;
            parameters[26].Value = model.user_index;
            parameters[27].Value = model.coordinates_x;
            parameters[28].Value = model.coordinates_y;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(HYSoft.Model.monitor_info model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update monitor_info set ");
            strSql.Append("index=@index,");
            strSql.Append("m_area_name=@m_area_name,");
            strSql.Append("m_area_id=@m_area_id,");
            strSql.Append("addr=@addr,");
            strSql.Append("type=@type,");
            strSql.Append("level=@level,");
            strSql.Append("population=@population,");
            strSql.Append("count=@count,");
            strSql.Append("contact_name1=@contact_name1,");
            strSql.Append("contact_mobile1=@contact_mobile1,");
            strSql.Append("contact_name2=@contact_name2,");
            strSql.Append("contact_mobile2=@contact_mobile2,");
            strSql.Append("contact_name3=@contact_name3,");
            strSql.Append("contact_mobile3=@contact_mobile3,");
            strSql.Append("upunit1=@upunit1,");
            strSql.Append("upcontact_name1=@upcontact_name1,");
            strSql.Append("upcontact_mobile1=@upcontact_mobile1,");
            strSql.Append("upunit2=@upunit2,");
            strSql.Append("upcontact_name2=@upcontact_name2,");
            strSql.Append("upcontact_mobile2=@upcontact_mobile2,");
            strSql.Append("intvalue1=@intvalue1,");
            strSql.Append("intvalue2=@intvalue2,");
            strSql.Append("intvalue3=@intvalue3,");
            strSql.Append("charvalue1=@charvalue1,");
            strSql.Append("charvalue2=@charvalue2,");
            strSql.Append("charvalue3=@charvalue3,");
            strSql.Append("user_index=@user_index,");
            strSql.Append("coordinates_x=@coordinates_x,");
            strSql.Append("coordinates_y=@coordinates_y");
            strSql.Append(" where index=@index and m_area_name=@m_area_name and m_area_id=@m_area_id and addr=@addr and type=@type and level=@level and population=@population and count=@count and contact_name1=@contact_name1 and contact_mobile1=@contact_mobile1 and contact_name2=@contact_name2 and contact_mobile2=@contact_mobile2 and contact_name3=@contact_name3 and contact_mobile3=@contact_mobile3 and upunit1=@upunit1 and upcontact_name1=@upcontact_name1 and upcontact_mobile1=@upcontact_mobile1 and upunit2=@upunit2 and upcontact_name2=@upcontact_name2 and upcontact_mobile2=@upcontact_mobile2 and intvalue1=@intvalue1 and intvalue2=@intvalue2 and intvalue3=@intvalue3 and charvalue1=@charvalue1 and charvalue2=@charvalue2 and charvalue3=@charvalue3 and user_index=@user_index and coordinates_x=@coordinates_x and coordinates_y=@coordinates_y ");
            SqlParameter[] parameters = {
					new SqlParameter("@index", SqlDbType.Int,4),
					new SqlParameter("@m_area_name", SqlDbType.VarChar,255),
					new SqlParameter("@m_area_id", SqlDbType.VarChar,50),
					new SqlParameter("@addr", SqlDbType.VarChar,255),
					new SqlParameter("@type", SqlDbType.VarChar,255),
					new SqlParameter("@level", SqlDbType.VarChar,255),
					new SqlParameter("@population", SqlDbType.Int,4),
					new SqlParameter("@count", SqlDbType.Int,4),
					new SqlParameter("@contact_name1", SqlDbType.VarChar,50),
					new SqlParameter("@contact_mobile1", SqlDbType.VarChar,50),
					new SqlParameter("@contact_name2", SqlDbType.VarChar,50),
					new SqlParameter("@contact_mobile2", SqlDbType.VarChar,50),
					new SqlParameter("@contact_name3", SqlDbType.VarChar,50),
					new SqlParameter("@contact_mobile3", SqlDbType.VarChar,50),
					new SqlParameter("@upunit1", SqlDbType.VarChar,255),
					new SqlParameter("@upcontact_name1", SqlDbType.VarChar,50),
					new SqlParameter("@upcontact_mobile1", SqlDbType.VarChar,50),
					new SqlParameter("@upunit2", SqlDbType.VarChar,255),
					new SqlParameter("@upcontact_name2", SqlDbType.VarChar,50),
					new SqlParameter("@upcontact_mobile2", SqlDbType.VarChar,50),
					new SqlParameter("@intvalue1", SqlDbType.Int,4),
					new SqlParameter("@intvalue2", SqlDbType.Int,4),
					new SqlParameter("@intvalue3", SqlDbType.Int,4),
					new SqlParameter("@charvalue1", SqlDbType.VarChar,255),
					new SqlParameter("@charvalue2", SqlDbType.VarChar,255),
					new SqlParameter("@charvalue3", SqlDbType.VarChar,255),
					new SqlParameter("@user_index", SqlDbType.Int,4),
					new SqlParameter("@coordinates_x", SqlDbType.VarChar,50),
					new SqlParameter("@coordinates_y", SqlDbType.VarChar,50)};
            parameters[0].Value = model.index;
            parameters[1].Value = model.m_area_name;
            parameters[2].Value = model.m_area_id;
            parameters[3].Value = model.addr;
            parameters[4].Value = model.type;
            parameters[5].Value = model.level;
            parameters[6].Value = model.population;
            parameters[7].Value = model.count;
            parameters[8].Value = model.contact_name1;
            parameters[9].Value = model.contact_mobile1;
            parameters[10].Value = model.contact_name2;
            parameters[11].Value = model.contact_mobile2;
            parameters[12].Value = model.contact_name3;
            parameters[13].Value = model.contact_mobile3;
            parameters[14].Value = model.upunit1;
            parameters[15].Value = model.upcontact_name1;
            parameters[16].Value = model.upcontact_mobile1;
            parameters[17].Value = model.upunit2;
            parameters[18].Value = model.upcontact_name2;
            parameters[19].Value = model.upcontact_mobile2;
            parameters[20].Value = model.intvalue1;
            parameters[21].Value = model.intvalue2;
            parameters[22].Value = model.intvalue3;
            parameters[23].Value = model.charvalue1;
            parameters[24].Value = model.charvalue2;
            parameters[25].Value = model.charvalue3;
            parameters[26].Value = model.user_index;
            parameters[27].Value = model.coordinates_x;
            parameters[28].Value = model.coordinates_y;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int index, string m_area_name, string m_area_id, string addr, string type, string level, int population, int count, string contact_name1, string contact_mobile1, string contact_name2, string contact_mobile2, string contact_name3, string contact_mobile3, string upunit1, string upcontact_name1, string upcontact_mobile1, string upunit2, string upcontact_name2, string upcontact_mobile2, int intvalue1, int intvalue2, int intvalue3, string charvalue1, string charvalue2, string charvalue3, int user_index, string coordinates_x, string coordinates_y)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from monitor_info ");
            strSql.Append(" where index=@index and m_area_name=@m_area_name and m_area_id=@m_area_id and addr=@addr and type=@type and level=@level and population=@population and count=@count and contact_name1=@contact_name1 and contact_mobile1=@contact_mobile1 and contact_name2=@contact_name2 and contact_mobile2=@contact_mobile2 and contact_name3=@contact_name3 and contact_mobile3=@contact_mobile3 and upunit1=@upunit1 and upcontact_name1=@upcontact_name1 and upcontact_mobile1=@upcontact_mobile1 and upunit2=@upunit2 and upcontact_name2=@upcontact_name2 and upcontact_mobile2=@upcontact_mobile2 and intvalue1=@intvalue1 and intvalue2=@intvalue2 and intvalue3=@intvalue3 and charvalue1=@charvalue1 and charvalue2=@charvalue2 and charvalue3=@charvalue3 and user_index=@user_index and coordinates_x=@coordinates_x and coordinates_y=@coordinates_y ");
            SqlParameter[] parameters = {
					new SqlParameter("@index", SqlDbType.Int,4),
					new SqlParameter("@m_area_name", SqlDbType.VarChar,255),
					new SqlParameter("@m_area_id", SqlDbType.VarChar,50),
					new SqlParameter("@addr", SqlDbType.VarChar,255),
					new SqlParameter("@type", SqlDbType.VarChar,255),
					new SqlParameter("@level", SqlDbType.VarChar,255),
					new SqlParameter("@population", SqlDbType.Int,4),
					new SqlParameter("@count", SqlDbType.Int,4),
					new SqlParameter("@contact_name1", SqlDbType.VarChar,50),
					new SqlParameter("@contact_mobile1", SqlDbType.VarChar,50),
					new SqlParameter("@contact_name2", SqlDbType.VarChar,50),
					new SqlParameter("@contact_mobile2", SqlDbType.VarChar,50),
					new SqlParameter("@contact_name3", SqlDbType.VarChar,50),
					new SqlParameter("@contact_mobile3", SqlDbType.VarChar,50),
					new SqlParameter("@upunit1", SqlDbType.VarChar,255),
					new SqlParameter("@upcontact_name1", SqlDbType.VarChar,50),
					new SqlParameter("@upcontact_mobile1", SqlDbType.VarChar,50),
					new SqlParameter("@upunit2", SqlDbType.VarChar,255),
					new SqlParameter("@upcontact_name2", SqlDbType.VarChar,50),
					new SqlParameter("@upcontact_mobile2", SqlDbType.VarChar,50),
					new SqlParameter("@intvalue1", SqlDbType.Int,4),
					new SqlParameter("@intvalue2", SqlDbType.Int,4),
					new SqlParameter("@intvalue3", SqlDbType.Int,4),
					new SqlParameter("@charvalue1", SqlDbType.VarChar,255),
					new SqlParameter("@charvalue2", SqlDbType.VarChar,255),
					new SqlParameter("@charvalue3", SqlDbType.VarChar,255),
					new SqlParameter("@user_index", SqlDbType.Int,4),
					new SqlParameter("@coordinates_x", SqlDbType.VarChar,50),
					new SqlParameter("@coordinates_y", SqlDbType.VarChar,50)			};
            parameters[0].Value = index;
            parameters[1].Value = m_area_name;
            parameters[2].Value = m_area_id;
            parameters[3].Value = addr;
            parameters[4].Value = type;
            parameters[5].Value = level;
            parameters[6].Value = population;
            parameters[7].Value = count;
            parameters[8].Value = contact_name1;
            parameters[9].Value = contact_mobile1;
            parameters[10].Value = contact_name2;
            parameters[11].Value = contact_mobile2;
            parameters[12].Value = contact_name3;
            parameters[13].Value = contact_mobile3;
            parameters[14].Value = upunit1;
            parameters[15].Value = upcontact_name1;
            parameters[16].Value = upcontact_mobile1;
            parameters[17].Value = upunit2;
            parameters[18].Value = upcontact_name2;
            parameters[19].Value = upcontact_mobile2;
            parameters[20].Value = intvalue1;
            parameters[21].Value = intvalue2;
            parameters[22].Value = intvalue3;
            parameters[23].Value = charvalue1;
            parameters[24].Value = charvalue2;
            parameters[25].Value = charvalue3;
            parameters[26].Value = user_index;
            parameters[27].Value = coordinates_x;
            parameters[28].Value = coordinates_y;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public HYSoft.Model.monitor_info GetModel(int index, string m_area_name, string m_area_id, string addr, string type, string level, int population, int count, string contact_name1, string contact_mobile1, string contact_name2, string contact_mobile2, string contact_name3, string contact_mobile3, string upunit1, string upcontact_name1, string upcontact_mobile1, string upunit2, string upcontact_name2, string upcontact_mobile2, int intvalue1, int intvalue2, int intvalue3, string charvalue1, string charvalue2, string charvalue3, int user_index, string coordinates_x, string coordinates_y)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 index,m_area_name,m_area_id,addr,type,level,population,count,contact_name1,contact_mobile1,contact_name2,contact_mobile2,contact_name3,contact_mobile3,upunit1,upcontact_name1,upcontact_mobile1,upunit2,upcontact_name2,upcontact_mobile2,intvalue1,intvalue2,intvalue3,charvalue1,charvalue2,charvalue3,user_index,coordinates_x,coordinates_y from monitor_info ");
            strSql.Append(" where index=@index and m_area_name=@m_area_name and m_area_id=@m_area_id and addr=@addr and type=@type and level=@level and population=@population and count=@count and contact_name1=@contact_name1 and contact_mobile1=@contact_mobile1 and contact_name2=@contact_name2 and contact_mobile2=@contact_mobile2 and contact_name3=@contact_name3 and contact_mobile3=@contact_mobile3 and upunit1=@upunit1 and upcontact_name1=@upcontact_name1 and upcontact_mobile1=@upcontact_mobile1 and upunit2=@upunit2 and upcontact_name2=@upcontact_name2 and upcontact_mobile2=@upcontact_mobile2 and intvalue1=@intvalue1 and intvalue2=@intvalue2 and intvalue3=@intvalue3 and charvalue1=@charvalue1 and charvalue2=@charvalue2 and charvalue3=@charvalue3 and user_index=@user_index and coordinates_x=@coordinates_x and coordinates_y=@coordinates_y ");
            SqlParameter[] parameters = {
					new SqlParameter("@index", SqlDbType.Int,4),
					new SqlParameter("@m_area_name", SqlDbType.VarChar,255),
					new SqlParameter("@m_area_id", SqlDbType.VarChar,50),
					new SqlParameter("@addr", SqlDbType.VarChar,255),
					new SqlParameter("@type", SqlDbType.VarChar,255),
					new SqlParameter("@level", SqlDbType.VarChar,255),
					new SqlParameter("@population", SqlDbType.Int,4),
					new SqlParameter("@count", SqlDbType.Int,4),
					new SqlParameter("@contact_name1", SqlDbType.VarChar,50),
					new SqlParameter("@contact_mobile1", SqlDbType.VarChar,50),
					new SqlParameter("@contact_name2", SqlDbType.VarChar,50),
					new SqlParameter("@contact_mobile2", SqlDbType.VarChar,50),
					new SqlParameter("@contact_name3", SqlDbType.VarChar,50),
					new SqlParameter("@contact_mobile3", SqlDbType.VarChar,50),
					new SqlParameter("@upunit1", SqlDbType.VarChar,255),
					new SqlParameter("@upcontact_name1", SqlDbType.VarChar,50),
					new SqlParameter("@upcontact_mobile1", SqlDbType.VarChar,50),
					new SqlParameter("@upunit2", SqlDbType.VarChar,255),
					new SqlParameter("@upcontact_name2", SqlDbType.VarChar,50),
					new SqlParameter("@upcontact_mobile2", SqlDbType.VarChar,50),
					new SqlParameter("@intvalue1", SqlDbType.Int,4),
					new SqlParameter("@intvalue2", SqlDbType.Int,4),
					new SqlParameter("@intvalue3", SqlDbType.Int,4),
					new SqlParameter("@charvalue1", SqlDbType.VarChar,255),
					new SqlParameter("@charvalue2", SqlDbType.VarChar,255),
					new SqlParameter("@charvalue3", SqlDbType.VarChar,255),
					new SqlParameter("@user_index", SqlDbType.Int,4),
					new SqlParameter("@coordinates_x", SqlDbType.VarChar,50),
					new SqlParameter("@coordinates_y", SqlDbType.VarChar,50)			};
            parameters[0].Value = index;
            parameters[1].Value = m_area_name;
            parameters[2].Value = m_area_id;
            parameters[3].Value = addr;
            parameters[4].Value = type;
            parameters[5].Value = level;
            parameters[6].Value = population;
            parameters[7].Value = count;
            parameters[8].Value = contact_name1;
            parameters[9].Value = contact_mobile1;
            parameters[10].Value = contact_name2;
            parameters[11].Value = contact_mobile2;
            parameters[12].Value = contact_name3;
            parameters[13].Value = contact_mobile3;
            parameters[14].Value = upunit1;
            parameters[15].Value = upcontact_name1;
            parameters[16].Value = upcontact_mobile1;
            parameters[17].Value = upunit2;
            parameters[18].Value = upcontact_name2;
            parameters[19].Value = upcontact_mobile2;
            parameters[20].Value = intvalue1;
            parameters[21].Value = intvalue2;
            parameters[22].Value = intvalue3;
            parameters[23].Value = charvalue1;
            parameters[24].Value = charvalue2;
            parameters[25].Value = charvalue3;
            parameters[26].Value = user_index;
            parameters[27].Value = coordinates_x;
            parameters[28].Value = coordinates_y;

            HYSoft.Model.monitor_info model = new HYSoft.Model.monitor_info();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public HYSoft.Model.monitor_info DataRowToModel(DataRow row)
        {
            HYSoft.Model.monitor_info model = new HYSoft.Model.monitor_info();
            if (row != null)
            {
                if (row["index"] != null && row["index"].ToString() != "")
                {
                    model.index = int.Parse(row["index"].ToString());
                }
                if (row["m_area_name"] != null)
                {
                    model.m_area_name = row["m_area_name"].ToString();
                }
                if (row["m_area_id"] != null)
                {
                    model.m_area_id = row["m_area_id"].ToString();
                }
                if (row["addr"] != null)
                {
                    model.addr = row["addr"].ToString();
                }
                if (row["type"] != null)
                {
                    model.type = row["type"].ToString();
                }
                if (row["level"] != null)
                {
                    model.level = row["level"].ToString();
                }
                if (row["population"] != null && row["population"].ToString() != "")
                {
                    model.population = int.Parse(row["population"].ToString());
                }
                if (row["count"] != null && row["count"].ToString() != "")
                {
                    model.count = int.Parse(row["count"].ToString());
                }
                if (row["contact_name1"] != null)
                {
                    model.contact_name1 = row["contact_name1"].ToString();
                }
                if (row["contact_mobile1"] != null)
                {
                    model.contact_mobile1 = row["contact_mobile1"].ToString();
                }
                if (row["contact_name2"] != null)
                {
                    model.contact_name2 = row["contact_name2"].ToString();
                }
                if (row["contact_mobile2"] != null)
                {
                    model.contact_mobile2 = row["contact_mobile2"].ToString();
                }
                if (row["contact_name3"] != null)
                {
                    model.contact_name3 = row["contact_name3"].ToString();
                }
                if (row["contact_mobile3"] != null)
                {
                    model.contact_mobile3 = row["contact_mobile3"].ToString();
                }
                if (row["upunit1"] != null)
                {
                    model.upunit1 = row["upunit1"].ToString();
                }
                if (row["upcontact_name1"] != null)
                {
                    model.upcontact_name1 = row["upcontact_name1"].ToString();
                }
                if (row["upcontact_mobile1"] != null)
                {
                    model.upcontact_mobile1 = row["upcontact_mobile1"].ToString();
                }
                if (row["upunit2"] != null)
                {
                    model.upunit2 = row["upunit2"].ToString();
                }
                if (row["upcontact_name2"] != null)
                {
                    model.upcontact_name2 = row["upcontact_name2"].ToString();
                }
                if (row["upcontact_mobile2"] != null)
                {
                    model.upcontact_mobile2 = row["upcontact_mobile2"].ToString();
                }
                if (row["intvalue1"] != null && row["intvalue1"].ToString() != "")
                {
                    model.intvalue1 = int.Parse(row["intvalue1"].ToString());
                }
                if (row["intvalue2"] != null && row["intvalue2"].ToString() != "")
                {
                    model.intvalue2 = int.Parse(row["intvalue2"].ToString());
                }
                if (row["intvalue3"] != null && row["intvalue3"].ToString() != "")
                {
                    model.intvalue3 = int.Parse(row["intvalue3"].ToString());
                }
                if (row["charvalue1"] != null)
                {
                    model.charvalue1 = row["charvalue1"].ToString();
                }
                if (row["charvalue2"] != null)
                {
                    model.charvalue2 = row["charvalue2"].ToString();
                }
                if (row["charvalue3"] != null)
                {
                    model.charvalue3 = row["charvalue3"].ToString();
                }
                if (row["user_index"] != null && row["user_index"].ToString() != "")
                {
                    model.user_index = int.Parse(row["user_index"].ToString());
                }
                if (row["coordinates_x"] != null)
                {
                    model.coordinates_x = row["coordinates_x"].ToString();
                }
                if (row["coordinates_y"] != null)
                {
                    model.coordinates_y = row["coordinates_y"].ToString();
                }
            }
            return model;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select [index],m_area_name,m_area_id,addr,type,level,population,count,contact_name1,contact_mobile1,contact_name2,contact_mobile2,contact_name3,contact_mobile3,upunit1,upcontact_name1,upcontact_mobile1,upunit2,upcontact_name2,upcontact_mobile2,intvalue1,intvalue2,intvalue3,charvalue1,charvalue2,charvalue3,user_index,coordinates_x,coordinates_y ");
            strSql.Append(" FROM monitor_info ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ");
            if (Top > 0)
            {
                strSql.Append(" top " + Top.ToString());
            }
            strSql.Append(" index,m_area_name,m_area_id,addr,type,level,population,count,contact_name1,contact_mobile1,contact_name2,contact_mobile2,contact_name3,contact_mobile3,upunit1,upcontact_name1,upcontact_mobile1,upunit2,upcontact_name2,upcontact_mobile2,intvalue1,intvalue2,intvalue3,charvalue1,charvalue2,charvalue3,user_index,coordinates_x,coordinates_y ");
            strSql.Append(" FROM monitor_info ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            strSql.Append(" order by " + filedOrder);
            return DbHelperSQL.Query(strSql.ToString());
        }

        /// <summary>
        /// 获取记录总数
        /// </summary>
        public int GetRecordCount(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) FROM monitor_info ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            object obj = DbHelperSQL.GetSingle(strSql.ToString());
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT * FROM ( ");
            strSql.Append(" SELECT ROW_NUMBER() OVER (");
            if (!string.IsNullOrEmpty(orderby.Trim()))
            {
                strSql.Append("order by T." + orderby);
            }
            else
            {
                strSql.Append("order by T.coordinates_y desc");
            }
            strSql.Append(")AS Row, T.*  from monitor_info T ");
            if (!string.IsNullOrEmpty(strWhere.Trim()))
            {
                strSql.Append(" WHERE " + strWhere);
            }
            strSql.Append(" ) TT");
            strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
            return DbHelperSQL.Query(strSql.ToString());
        }

        /*
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        {
            SqlParameter[] parameters = {
                    new SqlParameter("@tblName", SqlDbType.VarChar, 255),
                    new SqlParameter("@fldName", SqlDbType.VarChar, 255),
                    new SqlParameter("@PageSize", SqlDbType.Int),
                    new SqlParameter("@PageIndex", SqlDbType.Int),
                    new SqlParameter("@IsReCount", SqlDbType.Bit),
                    new SqlParameter("@OrderType", SqlDbType.Bit),
                    new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
                    };
            parameters[0].Value = "monitor_info";
            parameters[1].Value = "coordinates_y";
            parameters[2].Value = PageSize;
            parameters[3].Value = PageIndex;
            parameters[4].Value = 0;
            parameters[5].Value = 0;
            parameters[6].Value = strWhere;	
            return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
        }*/

        #endregion  BasicMethod
        #region  ExtensionMethod

        #endregion  ExtensionMethod
    }
}


